<!--银行票据兑付审核页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
      :labelWidth="75"
    >
      <template slot="endSlotOption">
        <amount-range-search label="交易金额" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('detials', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细弹出框 -->
    <details-dialog
      ref="detailsDialog"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></details-dialog>
  </div>
</template>
<script>
import { apiUrlConfig, detailsQuery } from "@/api/cnaps/bepsDraft/bank_note_pay_approve.js";
import DetailsDialog from "./components/BankNotePayApproveDetails";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";

export default {
  name: "BankNotePayReview",
  mixins: [listPageMixin],
  components: {
    AmountRangeSearch,
    DetailsDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: ["DRAFT_TYPE", "BIZ_TYPE", "CBFLAG", "DRAFT_CODE"],
      //  明细弹框数据
      // form表单字段
      formData: {
        id: "",
        draftNo: "",
        draftType: "",
        bizTypeCode: "",
        issuedBrno: "",
        issuedBrname: "",
        agentBrno: "",
        agentBrname: "",
        drawerAccount: "",
        drawerName: "",
        issuedActno: "",
        issuedName: "",
        payeeActno: "",
        payeeName: "",
        oriPayeeName: "",
        draftCode: "",
        cbflag: "",
        issuedDate: "",
        issuedAmount: "",
        payDate: "",
        draftMaturity: "",
        workdate: "",
        payAmount: "",
        payPassword: "",
        macKey: "",
        endorserNumber: "",
        endorserName: "",
        remarks: "",
        mdTlrno: "",
        mdTime: "",
        ckRemarks: "",
        ckTlrno: "",
        ckTime: "",
        audRemarks: "",
      },
      showSearch: true,
      // 查询参数
      queryParams: {
        idDate: "",
        idSeqNo: "",
        bizCtgyCode: "",
        issueDate: "",
        issueAmountMin: "",
        issueAmountMax: "",
      },
      formOptions: [],
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "220", align: "center" },
        {
          label: `票据类型`,
          prop: "draftType",
          width: "200",
          align: "center",
          dictCode: "DRAFT_TYPE",
        },
        {
          label: `出票日期`,
          prop: "issuedDate",
          width: "200",
          align: "center",
          type: "date",
        },
        {
          label: `票据号码`,
          prop: "draftNo",
          width: "200",
          align: "center",
        },
        {
          label: `出票行行名`,
          prop: "issuedBrname",
          width: "200",
          align: "center",
        },
        {
          label: `收款人名称`,
          prop: "payeeName",
          width: "200",
          align: "center",
        },
        {
          label: `出票金额`,
          prop: "issuedAmount",
          align: "center",
          type: "price",
        },
      ],
    };
  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "idSeqNo",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dict",
        prop: "bizCtgyCode",
        dict: "DRAFT_TYPE",
        defaultAttr: {
          label: "票据类型",
          placeholder: "请选择票据类型",
        },
      },
      {
        type: "singleDate",
        prop: "issueDate",
        defaultAttr: {
          label: "出票日期",
          placeholder: "请选择出票日期",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.issueAmountMin = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.issueAmountMax = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      return new Promise(function (resolve, reject) {
        this.$refs.amountRangeSearch.clearAmount();
        this.queryParams.issueAmountMin = "";
        this.queryParams.issueAmountMax = "";
      });
    },
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "detials":
          // 明细信息
          detailsQuery(row).then((res) => {
            this.formData = _.clone(res.result);
            this.$refs.detailsDialog.show();
          });
          break;
      }
    },
  },
};
</script>
